<template>
  <van-popup
    v-model:show="props.visible"
    position="bottom"
    :overlay="true"
  >
    <van-picker
      show-toolbar
      :title="Choosetitle"
      value-key="name"
      :columns="props.columns"
      @cancel="onCancel"
      @confirm="onConfirm"
    />
  </van-popup>
</template>

<script setup lang="ts">
const emit = defineEmits(['closeDialog', 'confirmValue'])
const props = defineProps({
  columns: {
    type: Object,
    required: true
  },
  type: {
    type: Number,
    default: 0
  },
  visible: {
    type: Boolean,
    required: true,
    default: true
  },
  Choosetitle: {
    typeof: String,
    required: true
  }
})

const onCancel = async () => {
  emit('closeDialog')
}
const onConfirm = async (val:any, index:any) => {
  emit('confirmValue', val, props.type, index)
}
</script>
